package com.rd.student.jiaji.class3.wangyanbo.exam;

import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Test2 {

    public static void m() throws IOException {



        ArrayList arrayList=new ArrayList();
        ArrayList arrayList1=new ArrayList();
        ArrayList arrayList2=new ArrayList();
        try (Scanner sc = new Scanner(new FileReader("player.txt"))) {
            sc.useDelimiter("，");
            while (sc.hasNext()) {
                String str = sc.next();
                arrayList.add(str);
            }
        }
            HashMap hashMap=new HashMap();
            for (int i = 0; i < arrayList.size(); i++) {
                if (i%2==1){
                    arrayList1.add(arrayList.get(i));
                }else {
                    arrayList2.add(arrayList.get(i));
                }
              }
        for (int i = 0; i < arrayList1.size(); i++) {
            hashMap.put(arrayList1.get(i),arrayList2.get(i));
        }

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入想要查找的球员名");
        String name=scanner.nextLine();
        for (Object o : hashMap.keySet()) {
            if (name==o){
                System.out.println(name+"所属球队："+hashMap.get(o));
            }else {
                System.out.println("不存在该球员");
            }
        }
    }
}
